var App = require('app');

App.FormEditView = Em.View.extend({

    templateName: 'templates/form/edit',
    didInsertElement: function() {
    	var me = this;
    	Nav.setPanelHeight();
		
    	Vari.CurrRecord = 0;
    	// left
		var fieldSelectionView = App.FieldSelectionView.create();
		var containerView = Em.View.views['nav_tab_view'];
		containerView.get('childViews').pushObject(fieldSelectionView);
		
		// right
		Vari.frm.fields.forEach(function(field) {			
			var type = field.type;
			var util = Util.capFirstLetter(type) + "Util";
			eval(util + ".show(field)");
		});
    	
    	$("#form_canvas_view").on(Drag.selectionDragToEvents);
		$("#form_canvas_view").on(Drag.fieldDragFromEvents, ".fieldset.editing");
	    $("#form_canvas_view").on(Drag.fieldDragToEvents, ".fieldset.editing");
	    
	    $("#form_canvas_view").on(Drag.fieldSetEvents, ".fieldset.editing");	    
	    
	    $("#submit").width($("#form_canvas_view").width() - 10 + "px");
   	    $(document).scroll(function(){
   	    	var w = $("#tab").width();
	   		var selection = new FixedBox(document.getElementById("tab"));
	   		selection.setStyle("position:fixed; top:30px;");			
			$("#tab").width(w);
   	    });
    }
});